home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / gfx / show / XanimAmiBeta4.lha / XanimAmigaBeta4 / xanim_picasso.c < prev    next >
C/C++ Source or Header  |  1995-04-16  |  4KB  |  141 lines

  1. #include <vilintuisup/screenmode.h>
  2. #include <vilintuisup/vilintuisup_protos.h>
  3. #include <graphics/gfxbase.h>
  4. #include <graphics/displayinfo.h>
  5.  
  6. /*#include <vilintuisup/vilintuisup.c> */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <ctype.h>
  10.  
  11. /* Here I fill in the neccessary options for a 320x200x8 screen. */
  12. /* Possible values for the depth is 8,15,16,24. If some other  */
  13. /* is supplied it will use the best mode possible. See Autodocs for more details. */
  14. struct TagItem tag[]={
  15.     {TAVIS_SCREEN_HEIGHT,200},
  16.     {TAVIS_SCREEN_WIDTH,320},
  17.     {TAVIS_SCREEN_DEPTH,8},
  18.     {TAG_DONE,0}
  19. };
  20. struct TagItem openscreentags[] = {
  21.     {  TAVIS_SCREEN_MODEID, 0 },    /* ti.Data used to check for OK from Req */
  22.     {  TAVIS_AUTOSCROLL, TRUE },
  23.     {  TAVIS_OPEN_BEHIND, FALSE },
  24.     {  TAVIS_SCREEN_HEIGHT, 0 },    /* to specify a new height */
  25.     {  TAVIS_SCREEN_WIDTH, 0 },
  26.     {  TAG_DONE, 0 }
  27. };
  28.  
  29. /*
  30.  *  TagItems for the VillageModeRequest call
  31.  */
  32.  
  33. struct TagItem requesttags[] = {
  34.     {  TAVIS_MINDEPTH, 8 },
  35.     {  TAVIS_MAXDEPTH, 16 },
  36.     {  TAG_DONE, 0 }
  37. };
  38.  
  39. struct Library *VilIntuiBase; /* Pointer to the Vilintuisup.library. */
  40. struct Screen *picasso_scr;     /* pointer to the screen structure */
  41. char *picasso_mem;                 /* pointer to the address of the Picasso screen */
  42.  
  43. /*
  44.  * It might be usefull to have a function, which will return the
  45.  * height, width or depth of a DisplayID. The next function will
  46.  * do the job. Specify an ID and the dimension you want to get.
  47.  * After a call the function returns the dimension value or -1.
  48.  */
  49.  
  50. /*
  51.  * Define more if you want to
  52.  */
  53.  
  54. #define GDF_HEIGHT  0
  55. #define GDF_WIDTH   1
  56. #define GDF_DEPTH   2
  57.  
  58. LONG GetDimFromID(ULONG ID, ULONG Tag)
  59. {
  60.     DisplayInfoHandle Handle;
  61.     struct DimensionInfo dimension;
  62.  
  63.     if (ID != INVALID_ID)
  64.     {
  65.         if (Handle = FindDisplayInfo(ID))
  66.         {
  67.             if (GetDisplayInfoData(Handle,(UBYTE *)&dimension,sizeof(dimension),DTAG_DIMS,0))
  68.             {
  69.                 switch(Tag) 
  70.                 {
  71.                     case GDF_HEIGHT:
  72.                         return dimension.Nominal.MaxY+1;
  73.                         break;
  74.                     case GDF_WIDTH:
  75.                         return dimension.Nominal.MaxX+1;
  76.                         break;
  77.                     case GDF_DEPTH:
  78.                         return dimension.MaxDepth;
  79.                         break;
  80.                     default:
  81. fprintf(stderr,"Invalid Tag for GetDimFromID() function\n");
  82.                         return -1;
  83.                         break;
  84.                 }
  85.             }
  86.         }
  87.     }
  88.     return -1;
  89. }
  90.  
  91.  
  92. OpenPicasso()
  93. {
  94.     int k;
  95.     int i;
  96.  
  97. /* the Picasso have to be installed and running to use this program. */
  98.     if(!(VilIntuiBase=OpenLibrary("vilintuisup.library",2))) {
  99.         printf("Can't open vilintuisup.library.");
  100.         exit(20);
  101.     }
  102. fprintf(stderr,"Vilintuisup.library opened\n");
  103.  
  104.     if ((openscreentags[0].ti_Data = VillageModeRequest(requesttags)) != INVALID_ID)
  105.     {
  106. fprintf(stderr,"Screenmode requestor opened and closed\n");
  107.         openscreentags[3].ti_Data = GetDimFromID(openscreentags[0].ti_Data, GDF_HEIGHT);
  108.         openscreentags[4].ti_Data = GetDimFromID(openscreentags[0].ti_Data, GDF_WIDTH);
  109. fprintf(stderr,"Screen Width= %ld\n",openscreentags[3].ti_Data);
  110. fprintf(stderr,"Screen Height=%ld\n",openscreentags[4].ti_Data);
  111.  
  112. /* Open the Screen with the supplied tags. And exit if it fails in any way.  */
  113. /* I could check what went wrong, but I don't. :) */
  114.         if(!(picasso_scr=OpenVillageScreenTagList(openscreentags)))
  115.         {
  116.             printf("Can't open screen...");
  117.             ClosePicasso();
  118.             exit(20);
  119.         }
  120.  
  121. /* Here I forbid multitasking. I think I only have to forbid it while  */
  122. /* doing the lock, but to be on the safe side... :) */
  123.         Forbid();
  124.  
  125. /* Here the actual pointer to the videomem on the Picasso is taken. */
  126.         picasso_mem=LockVillageScreen(picasso_scr);
  127.  
  128. /* Release pointer to videomem. */
  129.         UnLockVillageScreen(picasso_scr);
  130.         Permit();
  131.     }
  132.  
  133. /* The rest I think is quite obviuos. */
  134. }
  135.  
  136. ClosePicasso()
  137. {
  138.     if(picasso_scr)    CloseVillageScreen(picasso_scr);
  139.     if(VilIntuiBase) CloseLibrary(VilIntuiBase);
  140. }
  141.